<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" import="java.util.*,java.io.*, java.sql.*, dbAccess.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Create New Patient</title>
<link rel="stylesheet" type="text/css" href="css_files/style.css" />
<script type="text/javascript">
function changeNumberofDays(code)
{
	var mylist;
	if (code == "1")
	{
		mylist = document.forms["frmSearchByRange"].cmbStartMonth;
	}
	else
	{
		mylist = document.forms["frmSearchByRange"].cmbEndMonth;
	}
	var month = mylist.selectedIndex;
	if ((month == 0) || (month == 2) || (month == 4) || (month == 6) || (month == 7) || (month == 9) || (month == 11))
	{
		var days;
		if (code == 1)
		{
			days = document.forms["frmSearchByRange"].cmbStartDate;
		}
		else
		{
			days = document.forms["frmSearchByRange"].cmbEndDate;
		}
		days.options.length = 0;
		var i = 1;
		for (i = 1; i <= 31; i++)
		{
			var opt = document.createElement("option");
			days.options.add(opt);
			opt.text = i;
			opt.value = i;
		}
	}
	else if (month == 1)
	{
		var days;
		if (code == 1)
		{
			days = document.forms["frmSearchByRange"].cmbStartDate;
		}
		else
		{
			days = document.forms["frmSearchByRange"].cmbEndDate;
		}
		days.options.length = 0;
		var i = 1;
		for (i = 1; i <= 28; i++)
		{
			var opt = document.createElement("option");
			days.options.add(opt);
			opt.text = i;
			opt.value = i;
		}
	}
	else
	{
		var days;
		if (code == 1)
		{
			days = document.forms["frmSearchByRange"].cmbStartDate;
		}
		else
		{
			days = document.forms["frmSearchByRange"].cmbEndDate;
		}
		days.options.length = 0;
		var i = 1;
		for (i = 1; i <= 30; i++)
		{
			var opt = document.createElement("option");
			days.options.add(opt);
			opt.text = i;
			opt.value = i;
		}
	}
}
</script>
</head>
<body>
<table width="100%" border="1" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="150" height="125" valign="top"><img src="images/caduceus.gif" alt="" name="LogoLeft" width="150" height="125" id="LogoLeft" style="background-color: #0033FF" /></td>
    <td width="692" align="center" valign="middle"><h1 align="center">CADUCEUS HOSPITAL </h1></td>
    <td width="157" valign="top"><img src="images/hospital.jpg" alt="" name="LogoRight" width="150" height="125" id="LogoRight" style="background-color: #0033FF" /></td>
  </tr>
  <tr>
<td height="19" colspan="2" valign="top">Welcome Dr.<%=session.getAttribute("Name")%>&nbsp;<%=new java.util.Date() %></td>	
 	<td><a href="home.jsp" title="Logout">Logout</a></td>  </tr>
</table>
<table width="100%" border="1" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr>
    <td width="189" valign="top">
    	<form name="frmSearchByRange" method="post" action="doc2appt.jsp">
    	<table>
    		<tr>
    			<td>
    				<strong>Search For Appointments:</strong>
    			</td>
    		</tr>
    		<tr>
    			<td>
    				<p align="center"><strong>Start Date Range </strong></p>
                 <p align="center"><strong>Year</strong> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                       <select name="cmbStartYear" id="cmbStartYear">
                       <option>2009</option>
                       </select>
                                </p>
                 <p align="center"><strong>Month</strong>&nbsp;&nbsp;&nbsp;
                       <select name="cmbStartMonth" id="cmbStartMonth" onchange="changeNumberofDays('1')">
                         <option>January</option>
                         <option>February</option>
                         <option>March</option>
                         <option>April</option>
                         <option>May</option>
                         <option>June</option>
                         <option>July</option>
                         <option>August</option>
                         <option>September</option>
                         <option>October</option>
                         <option>November</option>
                         <option>December</option>
                       </select>
                   </p>
                 <p align="center"><strong>Date</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                       <select name="cmbStartDate" id="cmbStartDate">
                         <option>1</option>
                         <option>2</option>
                         <option>3</option>
                         <option>4</option>
                         <option>5</option>
                         <option>6</option>
                         <option>7</option>
                         <option>8</option>
                         <option>9</option>
                         <option>10</option>
                         <option>11</option>
                         <option>12</option>
                         <option>13</option>
                         <option>14</option>
                         <option>15</option>
                         <option>16</option>
                         <option>17</option>
                         <option>18</option>
                         <option>19</option>
                         <option>20</option>
                         <option>21</option>
                         <option>22</option>
                         <option>23</option>
                         <option>24</option>
                         <option>25</option>
                         <option>26</option>
                         <option>27</option>
                         <option>28</option>
                         <option>29</option>
                         <option>30</option>
                         <option>31</option>
                       </select>
                   </p>
                 <p align="center">&nbsp;</p>
    			</td>
    		</tr>
    		<tr>
    			<td>
    				<p align="center">End Date Range </p>
                 <p align="center">Year &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                       <select name="cmbEndYear" id="cmbEndYear">
                         <option>2009</option>
                                            </select>
                                </p>
                 <p align="center">Month &nbsp;&nbsp;&nbsp;
                   <select name="cmbEndMonth" id="select2" onChange="changeNumberofDays('2')">
                     <option>January</option>
                     <option>February</option>
                     <option>March</option>
                     <option>April</option>
                     <option>May</option>
                     <option>June</option>
                     <option>July</option>
                     <option>August</option>
                     <option>September</option>
                     <option>October</option>
                     <option>November</option>
                     <option>December</option>
                   </select>
                 </p>
                 <p align="center">Date&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                       <select name="cmbEndDate" id="select3">
                         <option>1</option>
                         <option>2</option>
                         <option>3</option>
                         <option>4</option>
                         <option>5</option>
                         <option>6</option>
                         <option>7</option>
                         <option>8</option>
                         <option>9</option>
                         <option>10</option>
                         <option>11</option>
                         <option>12</option>
                         <option>13</option>
                         <option>14</option>
                         <option>15</option>
                         <option>16</option>
                         <option>17</option>
                         <option>18</option>
                         <option>19</option>
                         <option>20</option>
                         <option>21</option>
                         <option>22</option>
                         <option>23</option>
                         <option>24</option>
                         <option>25</option>
                         <option>26</option>
                         <option>27</option>
                         <option>28</option>
                         <option>29</option>
                         <option>30</option>
                         <option>31</option>
                       </select>
                   </p>
               <p align="center">&nbsp;</p>
    			</td>
    		</tr>
    		<tr>
    			<td>
    				 <input name="cmdSearch" type="submit" id="cmdSearch" value="Search">
    			</td>
    		</tr>
    	</table>
    	</form>
    	
    </td>
    <%
    String callerId = "doctorHome";
    %>
    <td width="740" rowspan="2" class="style2", valign="top"><span class="style5"><strong>Edit Doctor Personal Information</strong></span>
    <form id="frmDoctor" name="frmDoctor" method="post" action="doctorAddSave.jsp?action=update&callerId=<%=callerId %>">
    
    <%
		Login lgn = new Login();
		ResultSet rs;
		int docId = 0;
		String firstName = "unknown";
		String lastName = "unknown";
		//String SIN = session.getAttribute("SIN").toString();
		//out.print(session.getAttribute("SIN").toString());
		
		String emailAddress = "unknown";
		String phoneNumber = "unknown";
		String homeAddress = "unknown";
		String gender = "unknown";
		String dateOfBirth = "unknown";
		String password = "unknown";
		String DocRoom = "unknown";
		String DocBuilding = "unknown";
		int sin2 = 0;
		rs = lgn.getDocInfo(Integer.parseInt((String)session.getAttribute("SIN")));
		if (rs != null)
		{
			while (rs.next())
			{
				docId = Integer.parseInt(session.getAttribute("DocId").toString()); 
				firstName = session.getAttribute("FirstName").toString();
				lastName = session.getAttribute("LastName").toString();
				sin2 = rs.getInt("tbl_doctor.SIN"); 
				emailAddress = session.getAttribute("EmailAddress").toString();
				phoneNumber = session.getAttribute("Phone").toString();
				homeAddress = session.getAttribute("HomeAddress").toString();
				gender = session.getAttribute("Gender").toString();
				dateOfBirth = session.getAttribute("DateOfBirth").toString();
				password = session.getAttribute("Password").toString();
				DocRoom = session.getAttribute("DocRoom").toString();
				DocBuilding = session.getAttribute("DocBuilding").toString();
			}
		}
	%>
    
    <table width="647">
		<tr>
			<td width="117"><strong>
			  First Name					</strong></td>
		  <td width="518"><input name="fName" type="text" id="fName" value = <%=firstName%> /></td>
		</tr>
				
		<tr>
			<td><strong>
			  Last Name
			</strong></td>
			<td><input name="lName" type="text" id="lName" value = <%=lastName%> /></td>
		</tr>
				
		<tr>
			<td><strong>
			  Phone Number
			</strong></td>
			<td><input name="phoneNumber" type="text" id="phoneNumber" value = <%=phoneNumber%> /></td>
		</tr>
				
		<tr>
			<td><strong>
			  Email Address
			</strong></td>
			<td><input name="emailAddress" type="text" id="emailAddress" value = <%=emailAddress%> /></td>
		</tr>
		<tr>
		  <td><strong>Password</strong></td>
		  <td><input name="password" type="text" id="password" value = <%=password%> /></td>
	    </tr>
	    
	    <tr>
		  <td><strong>HomeAddress</strong></td>
		  <td><input name="homeAddress" type="text" id="homeAddress" value = <%=homeAddress%> /></td>
	    </tr>

	    <tr>
		  <td><strong>
			  Gender
			</strong></td>
			<td>
				<%
					if (gender.equals("M"))
					{
				%>
					 <input name="gender" type="radio" value="male" checked/> Male
					 <input name="gender" type="radio" value="female"/> Female
				<%	
					}
					else
					{
				%>
					 <input name="gender" type="radio" value="male"/> Male
					 <input name="gender" type="radio" value="female" checked/> Female
				<%		
					}
				%>
			</td>
	    </tr>
	    
	    <tr>
		  <td><strong>DateOfBirth</strong></td>
		  <td><input name="dateOfBirth" type="text" id="dateOfBirth" value = <%=dateOfBirth%> /></td>
	    </tr>
	    	    
	    <tr>
		  <td><strong>Doctor Room</strong></td>
		  <td><input name="docRoom" type="text" id="docRoom" value = <%=DocRoom%> /></td>
	    </tr>

	    <tr>
		  <td><strong>Doctor Building</strong></td>
		  <td><input name="docBuilding" type="text" id="docBuilding" value = <%=DocBuilding%> /></td>
	    </tr>
	    <tr>
		  <td><strong>Doctor Building</strong></td>
		  <td><input name="docSIN" type="text" id="docSIN" value=<%=sin2%> /></td>
	    </tr>
	    	    
	</table>
      <p><input name="cmdSave" type="submit" id="cmdSave" value="Save" />
    </p>
    </form>
    </td>

  </tr>
  
  <tr>
    <td valign="top" class="style2"><p align="center"><strong>Quicklinks</strong></p>
    <p><a href="patientListforDoc.jsp">View List of Patients</a></p>
    <p><a href="editDoctorInfoByDoc.jsp">Change My Personal Information</a></p>
    <p><a href="http://www.webmd.com">WebMD</a></p>
	<p><a href="doctorHome.jsp">Back to Homepage </a></p>
	</td>
   </tr>
 </table>
</body>
</html>